package xin.marcher.module.rights.domain.bo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import xin.marcher.module.rights.support.LoginUser;

import java.util.Collection;
import java.util.Set;

/**
 *
 */
@Data
@NoArgsConstructor
public class EshopUserDetails extends LoginUser implements UserDetails {
    private static final long serialVersionUID = 1L;

    private String password;

    private Set<String> permissionCodes;

    public LoginUser toLoginUser() {
        LoginUser loginUser = new LoginUser();
        loginUser.setUserId(this.getUserId());
        loginUser.setUsername(this.getUsername());
        return loginUser;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
